package com.atguigu.gmall.search.pojo;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

/**
 * @description:
 * @author: xie.zh
 * @create: 2021.03.16   01:49
 * @version: 1.0
 */
@Document(indexName = "goods", type = "info", shards = 3, replicas = 2)
@Data
public class Goods {

    //商品列表所需字段 sku
    @Id
    private Long skuId;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;
    @Field(type = FieldType.Keyword, index = false)
    private String subTitle;
    @Field(type = FieldType.Double)
    private Double price;
    @Field(type = FieldType.Keyword, index = false)
    private String defaultImage;

    //排序和分页所需字段
    @Field(type = FieldType.Long)
    private Long sales; //销量
    @Field(type = FieldType.Date)
    private Date createTime; //新品
    @Field(type = FieldType.Boolean)
    private Boolean store; //是否有货

    //品牌过滤
    @Field(type = FieldType.Long)
    private Long brandId;
    @Field(type = FieldType.Keyword)
    private String brandName;
    @Field(type = FieldType.Keyword)
    private String logo;

    //分类聚合
    @Field(type = FieldType.Long)
    private Long categoryId;
    @Field(type = FieldType.Keyword)
    private String categoryName;

    @Field(type = FieldType.Nested)
    private List<SearchAttrValueVo> searchAttrs;
}
